package com.visionforge.sdk;

/**
 * VisionForge SDK演示程序，展示如何使用Java SDK进行各种AI检测
 */
public class VisionForgeDemo {

    public static void main(String[] args) {
        // 创建VisionForge SDK实例
        VisionForgeSDK sdk = new VisionForgeSDK();
        
        System.out.println("===== VisionForge SDK Java版演示程序 =====\n");
        
        // 演示1: 手机打电话检测
        System.out.println("1. 手机打电话检测示例");
        String callPhoneImagePath = "E:\\PyProject_yywl\\01ultralytics-main-garbage\\SDKDemo\\CSharp\\AiProjectCSharp\\AiProjectCSharp\\bin\\Debug\\TestImg\\004打电话识别004callPhone\\打电话1.jpg";
        testCallPhoneDetection(sdk, callPhoneImagePath);
        
        System.out.println("\n" + "=" .repeat(50) + "\n");
        
        // 演示2: 人员打架检测
        System.out.println("2. 人员打架检测示例");
        String fightingImagePath = "E:\\PyProject_yywl\\01ultralytics-main-garbage\\SDKDemo\\CSharp\\AiProjectCSharp\\AiProjectCSharp\\bin\\Debug\\TestImg\\005人员打架005fight\\打架1.jpg";
        testFightingDetection(sdk, fightingImagePath);
        
        System.out.println("\n" + "=" .repeat(50) + "\n");
        
        // 演示3: 人员打架检测3号图片
        System.out.println("3. 人员打架检测3号图片示例");
        String fightingImagePath3 = "E:\\PyProject_yywl\\01ultralytics-main-garbage\\SDKDemo\\CSharp\\AiProjectCSharp\\AiProjectCSharp\\bin\\Debug\\TestImg\\005人员打架005fight\\打架3.jpg";
        testFightingDetection(sdk, fightingImagePath3);
        
        System.out.println("\n所有检测演示完成!");
    }
    
    /**
     * 测试手机打电话检测
     * @param sdk VisionForge SDK实例
     * @param imagePath 图片路径
     */
    private static void testCallPhoneDetection(VisionForgeSDK sdk, String imagePath) {
        System.out.println("\n开始测试手机打电话检测: " + imagePath);
        DetectionResult result = sdk.detectAndSaveResult(imagePath, ModelType.CALL_PHONE);
        if (result != null) {
            System.out.println("手机打电话检测完成，结果已保存");
        } else {
            System.out.println("手机打电话检测失败");
        }
    }
    
    /**
     * 测试人员打架检测
     * @param sdk VisionForge SDK实例
     * @param imagePath 图片路径
     */
    private static void testFightingDetection(VisionForgeSDK sdk, String imagePath) {
        System.out.println("\n开始测试人员打架检测: " + imagePath);
        DetectionResult result = sdk.detectAndSaveResult(imagePath, ModelType.FIGHTING);
        if (result != null) {
            System.out.println("人员打架检测完成，结果已保存");
        } else {
            System.out.println("人员打架检测失败");
        }
    }
    
    /**
     * 生成重复字符的字符串，Java 11以下版本的辅助方法
     * @param str 要重复的字符
     * @param count 重复次数
     * @return 重复后的字符串
     */
    private static String repeat(String str, int count) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < count; i++) {
            sb.append(str);
        }
        return sb.toString();
    }
}